{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "405fc4bc-8ce0-46fa-9ede-8446ae01f70f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1~100中所有数的和为: 5050\n",
      "1~100中所有奇数的和: 2500\n",
      "1~100中所有偶数的和: 2550\n"
     ]
    }
   ],
   "source": [
    "sumAll=0;sum_odd = 0; sum_even = 0\n",
    "for i in range(1, 101):\n",
    "    sumAll+=i\n",
    "    if i % 2 != 0:      #奇数\n",
    "        sum_odd += i\n",
    "    else:               #偶数\n",
    "        sum_even += i\n",
    "print(\"1~100中所有数的和为:\", sumAll)\n",
    "print(\"1~100中所有奇数的和:\", sum_odd)\n",
    "print(\"1~100中所有偶数的和:\", sum_even)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bfe73a9b-3257-4e78-aaa5-77fda5df7b8e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
